package util;

import java.util.*;
import java.util.Properties;

import util.Properties.*;

public class PropertiesReader {

    private static final Properties props = new Properties();

    private static String srcGenPath;

    static {
        try {
            props.load(PropertiesReader.class.getResourceAsStream("/generator.properties"));
            Properties propsSrcGenPath = new Properties();
            propsSrcGenPath.load(PropertiesReader.class.getResourceAsStream("/workflow.properties"));

            srcGenPath = propsSrcGenPath.getProperty(Dirs.srcGenPath.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String _(Prop key) {
        return get(key.toString());
    }

    public static String get(String key) {
        if(key.equals(Dirs.srcGenPath.toString()))
            return srcGenPath;

        return props.getProperty(key);
    }

    public static String getTemplate(String key, List<String> args) throws Throwable {
        return Templates.valueOf(key).getValue(args.toArray(new String[] {}));
    }
}
